<?php

namespace app\api\controller\tieba;

use app\api\service\tieba\DerivativeService;
use think\facade\Request;

class Derivative
{
    protected $Service;
    public function __construct()
    {
        $this->Service = DerivativeService::getInstance();
    }

    /**
     * @auth('仿写作品任务创建','贴吧作品仿写')
     * @param('link','来源地址','require')
     * @param('title',‘原标题','require')
     * @param('content','原内容','require')
     * @param('images','图片数组','array')
     * @param('new_title','原创标题','require')
     * @param('source_platform','来源平台','require')
     * @param('comment','评论','require')
     * @param('data','分发数组','array')
     * @param('type','内容类型','require')
     * @param('uuid','分发id','require')
     * @param('pub_time','发布时间','require')
     * @return \think\response\Json
     */
    public function addEvent(){
        $params = Request::post();
        $result = $this->Service->addEvent($params);
        return writeJson(200,$result,'创建成功！');
    }

    /**
     * @auth('仿写作品任务编辑','贴吧作品仿写')
     * @param('id','任务id','require')
     * @return \think\response\Json
     */
    public function upEvent(){
        $params = Request::post();
        $result = $this->Service->upEvent($params);
        return writeJson(200,$result,'编辑成功！');
    }

    /**
     * @auth('仿写作品去重判断','贴吧作品仿写')
     * @param('content_id','原文id','require')
     * @param('source_platform','平台','require')
     * @return \think\response\Json
     */
    public function check(){
        $params = Request::get();
        $result = $this->Service->check($params);
        return writeJson(200,$result,'有效作品！');
    }

    /**
     * @auth('仿写作品任务列表','贴吧作品仿写')
     * @param('user_key','用户类型','require')
     * @return \think\response\Json
     */
    public function getList(){
        $params = Request::get();
        $result = $this->Service->getList($params);
        return writeJson(200,$result,'数据列表！');
    }

    /**
     * @auth('仿写作品任务列表明细','贴吧作品仿写')
     * @param('list_id','任务id','require')
     * @return \think\response\Json
     */
    public function getEvent(){
        $params = Request::get();
        $result = $this->Service->getEvent($params);
        return writeJson(200,$result,'数据列表！');
    }

    public function excel(){
        $params = Request::get();
        $result = $this->Service->excel($params);
        return writeJson(200,$result,'导出成功');
    }



    /**
     * @auth('仿写作品任务回填链接','贴吧作品仿写')
     * @param('id','任务id','require')
     * @param('backfill_url','回填地址','require')
     * @return \think\response\Json
     */
    public function backfill(){
        $params = Request::post();
        $result = $this->Service->backfill($params);
        return writeJson(200,$result,'回填成功！');
    }

    public function checklink(){
        $params = Request::post();
        $this->Service->checklink($params);
        return writeJson(200,'','提交成功');
    }

    public function checkUrl(){
        $params = Request::post();
        $this->Service->checkUrl($params);
        return writeJson(200,'','测试完成');
    }
}
